<?php
class User extends Database
{
    protected $_username;
    protected $_password;
    protected $_email;
    public function __construct()
    {
        $this->connect();
    }
    public function setUsername($u)
    {
        $this->_username=$u;
    }
    public function getUsername()
    {
        return $this->_username;
    }
    public function setPassword($p)
    {
        $this->_password=$p;
    }
    public function getPassword()
    {
        return $this->_password;
    }
    public function setEmail($e)
    {
        $this->_email=$e;
    }
    public function getEmail()
    {
        return $this->_email;
    }
    public function check_login()
    {
        $sql="select * from user where user_name='".$this->_username."' and pass_word='".md5($this->_password)."';";
        $this->query($sql);
        if($this->num_rows()==0)
            return false;
        else
        {
            return $this->fetch();
            }
    }
	public function show_user()
	{
		$sql="select * from user order by level_id asc";
		$this->query($sql);
		while($row=$this->fetch())
		{
			$data[]=$row;
		}
		return $data;
	}
	public function xoa_user($id)
	{
		$sql="DELETE FROM user WHERE user_id = '".$id."'";
		$this->query($sql);
	}
	public function show_level()
	{
		$sql="select * from level";
		$this->query($sql);
		if($this->num_rows() !=false)
		{
			while($row=$this->fetch())
			{
				$data[]=$row;
			}
			return $data;
		}
	}
}